var tgd = tgd || {};
tgd.Contests = tgd.Contests || {};
tgd.Contests.SameGame = tgd.Contests.SameGame || {};
tgd.Contests.SameGame.Solver = tgd.Contests.SameGame.Solver || {};
tgd.Contests.SameGame.View = tgd.Contests.SameGame.View || {};

tgd.Contests.SameGame.View.Field = function(grid) {
	var field = document.createElement("table");

	for (var row = 0; row < grid.length; ++row) {
		var fieldRow = document.createElement("tr");
		field.appendChild(fieldRow);
		for (var col = 0; col < grid[row].length; ++col) {
			var block = document.createElement("td");
			block.style.backgroundColor = (grid[row][col]) ? grid[row][col].HTMLColor : "";
			fieldRow.appendChild(block);
		}
	}

	return field;
}
